From 57a61d6f9f4f9e581ea69eb9179f3e6b7078c8fd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 29 Sep 2004 05:04:31 +0000 Subject: [PATCH] Skip selectable labels when looking for the initial focus widget. 2004-09-29 Matthias Clasen * gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when looking for the initial focus widget. * gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels in the regular focus chain again. --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ gtk/gtkdialog.c | 15 +++++++++++++-- gtk/gtklabel.c | 37 ------------------------------------- 6 files changed, 45 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29aca957e0..9abf0180a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-09-29 Matthias Clasen + + * gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when + looking for the initial focus widget. + + * gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels + in the regular focus chain again. + 2004-09-28 Matthias Clasen * gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 29aca957e0..9abf0180a0 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-09-29 Matthias Clasen + + * gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when + looking for the initial focus widget. + + * gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels + in the regular focus chain again. + 2004-09-28 Matthias Clasen * gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 29aca957e0..9abf0180a0 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-09-29 Matthias Clasen + + * gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when + looking for the initial focus widget. + + * gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels + in the regular focus chain again. + 2004-09-28 Matthias Clasen * gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 29aca957e0..9abf0180a0 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-09-29 Matthias Clasen + + * gtk/gtkdialog.c (gtk_dialog_map): Skip selectable labels when + looking for the initial focus widget. + + * gtk/gtklabel.c (gtk_label_focus): Remove to put selectable labels + in the regular focus chain again. + 2004-09-28 Matthias Clasen * gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render): Don't diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index d42c039b08..81757a7ffa 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -29,6 +29,7 @@ #include "gtkbutton.h" #include "gtkdialog.h" #include "gtkhbbox.h" +#include "gtklabel.h" #include "gtkhseparator.h" #include "gtkmarshalers.h" #include "gtkvbox.h" @@ -329,6 +330,9 @@ gtk_dialog_delete_event_handler (GtkWidget *widget, * widget in the tab chain, but if this results in the focus * ending up on one of the response widgets _other_ than the * default response, we focus the default response instead. + * + * Additionally, skip selectable labels when looking for the + * right initial focus widget. */ static void gtk_dialog_map (GtkWidget *widget) @@ -342,7 +346,11 @@ gtk_dialog_map (GtkWidget *widget) { GList *children, *tmp_list; - g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD); + do + { + g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD); + } + while (GTK_IS_LABEL (window->focus_widget)); tmp_list = children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area)); @@ -350,7 +358,10 @@ gtk_dialog_map (GtkWidget *widget) { GtkWidget *child = tmp_list->data; - if (child == window->focus_widget && child != window->default_widget && window->default_widget) + if (window->focus_widget == NULL || + (child == window->focus_widget && + child != window->default_widget && + window->default_widget)) { gtk_widget_grab_focus (window->default_widget); break; diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 0f7befa383..fe60022204 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -149,8 +149,6 @@ static gboolean gtk_label_mnemonic_activate (GtkWidget *widget, gboolean group_cycling); static void gtk_label_setup_mnemonic (GtkLabel *label, guint last_key); -static gboolean gtk_label_focus (GtkWidget *widget, - GtkDirectionType direction); /* For selectable lables: */ static void gtk_label_move_cursor (GtkLabel *label, @@ -252,7 +250,6 @@ gtk_label_class_init (GtkLabelClass *class) widget_class->hierarchy_changed = gtk_label_hierarchy_changed; widget_class->screen_changed = gtk_label_screen_changed; widget_class->mnemonic_activate = gtk_label_mnemonic_activate; - widget_class->focus = gtk_label_focus; class->move_cursor = gtk_label_move_cursor; class->copy_clipboard = gtk_label_copy_clipboard; @@ -2945,40 +2942,6 @@ gtk_label_get_use_underline (GtkLabel *label) return label->use_underline; } -static gboolean -gtk_label_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkLabel *label = GTK_LABEL (widget); - GdkEvent *current_event; - gboolean is_control_tab = FALSE; - - /* We want to be in the tab chain only if we are selectable - * and Control-[Shift]Tab is pressed - */ - if (label->select_info == NULL) - return FALSE; - - current_event = gtk_get_current_event (); - - if (current_event) - { - if (current_event->type == GDK_KEY_PRESS && - (current_event->key.keyval == GDK_Tab || - current_event->key.keyval == GDK_KP_Tab || - current_event->key.keyval == GDK_ISO_Left_Tab) && - (current_event->key.state & GDK_CONTROL_MASK) != 0) - is_control_tab = TRUE; - - gdk_event_free (current_event); - } - - if (is_control_tab) - return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction); - else - return FALSE; -} - /* Compute the X position for an offset that corresponds to the "more important * cursor position for that offset. We use this when trying to guess to which * end of the selection we should go to when the user hits the left or -- 2.30.2